package com.venutech.gongan.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.venutech.gongan.dao.DictTypeMapper;
import com.venutech.gongan.entity.DictType;
import com.venutech.gongan.model.ResultFormat;
import com.venutech.gongan.service.DictTypeService;
import com.venutech.gongan.util.ResultUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DictTypeServiceImpl implements DictTypeService {
    @Resource
    private DictTypeMapper dictTypeMapper;


    @Override
    public ResultFormat insert(DictType dictType) {
        Integer insert = dictTypeMapper.insert(dictType);
        if (insert > 0) {
            return ResultUtil.success();
        }else {
            return ResultUtil.error(100,"添加失败");
        }
    }

    @Override
    public int deleteById(Integer dict_id) {
        return dictTypeMapper.deleteById(dict_id);
    }

    @Override
    public DictType getById(Integer dict_id) {
        return dictTypeMapper.getById(dict_id);
    }

    @Override
    public int updateDictType(DictType dictType) {
        return dictTypeMapper.updateDictType(dictType);
    }

    @Override
    public List<DictType> getSelectAll() {
        return dictTypeMapper.getSelectAll();
    }

    @Override
    public Page<DictType> getInfo(Integer pageNo, Integer pageSize, String begintime, String endtime, String badw, String dict_name) {
        Page<DictType> page = new Page<>(pageNo,pageSize);
        List<DictType> list = dictTypeMapper.getInfo(begintime,endtime,badw,page,dict_name);
        return page.setRecords(list);
    }

}
